package com.crud.generator.model;

import lombok.Data;
import lombok.Builder;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;

/**
 * 实体类元数据
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class EntityMetadata {
    
    /** 类名 */
    private String className;
    
    /** 包名 */
    private String packageName;
    
    /** 表元数据 */
    private TableMetadata tableMetadata;
    
    /** 作者 */
    private String author;

    @Builder.Default
    private boolean enableRedis = false;

    @Builder.Default
    private boolean enableSecurity = false;

    @Builder.Default
    private String cacheName = "";

    @Builder.Default
    private String securityRole = "ROLE_ADMIN";

    @Builder.Default
    private String securityDefaultTenant = "default";

    @Builder.Default
    private String securityDefaultUsername = "admin";

    @Builder.Default
    private String securityDefaultPassword = "Admin@123";

    @Builder.Default
    private String securityTokenHeader = "Authorization";

    @Builder.Default
    private String securityTokenPrefix = "Bearer ";

    @Builder.Default
    private String securityTenantHeader = "X-Tenant-Id";

    @Builder.Default
    private String jwtSecret = "";

    @Builder.Default
    private long jwtExpirationSeconds = 3600L;

    @Builder.Default
    private long jwtRefreshExpirationSeconds = 2592000L;
    
    /**
     * 获取完整的类名
     */
    public String getFullClassName() {
        return packageName + "." + className;
    }
    
    /**
     * 获取小写类名(用于变量名)
     */
    public String getLowerClassName() {
        return className.substring(0, 1).toLowerCase() + className.substring(1);
    }
}
